$(function () {
    layui.use('upload', function () {
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '.uploadImg',
            url: ctx+'/upload/uploadImg',
            size: 20480,
            accept: 'images',
            exts:'jpg|png|JPEG|GIF',
            method:'post',
            data:{},
            before:function(){
            },
            done: function (r) {
                if("0" == r.code){
                    parent.layer.alert("上传成功");
                    $(".resourceImg").remove();
                    var html = '<div class="col-sm-3 col-md-3 resourceImg">' +
                        '   <div class="thumbnail">' +
                        '      <img class="imgUrl" data-toggle="tooltip" imgName="'+r.fileName+'" title="点击预览大图" src="'+r.fileUrl+'">' +
                        '   </div>' +
                        '</div>';
                    $(".uploadImg").before(html);
                    $(":hidden[name=img]").val(r.fileUrl);
                    $(":hidden[name=headImg]").val(r.fileUrl);
                    $(":hidden[name=value]").val(r.fileUrl);
                    $("[data-toggle='tooltip']").tooltip();
                    $('#logImg img').viewer({
                        "navbar":false,
                        "title":false,
                        "toolbar":false,
                        "tooltip":false,
                        "loading":false
                    });
                }else{
                    parent.layer.alert(r.msg);
                }
            },
            error: function (r) {
                parent.layer.alert(r.msg);
            }
        });
    });

    layui.use('upload', function () {
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '.uploadImg1',
            url: ctx+'/upload/uploadImg',
            size: 20480,
            accept: 'images',
            exts:'jpg|png|JPEG|GIF',
            method:'post',
            data:{},
            before:function(){
            },
            done: function (r) {
                if("0" == r.code){
                    parent.layer.alert("上传成功");
                    $(".resourceImg1").remove();
                    var html = '<div class="col-sm-3 col-md-3 resourceImg">' +
                        '   <div class="thumbnail">' +
                        '      <img class="imgUrl" data-toggle="tooltip" imgName="'+r.fileName+'" title="点击预览大图" src="'+r.fileUrl+'">' +
                        '   </div>' +
                        '</div>';
                    $(".uploadImg1").before(html);
                    $(":hidden[name=img1]").val(r.fileUrl);
                    $('#logImg1 img').viewer({
                        "navbar":false,
                        "title":false,
                        "toolbar":false,
                        "tooltip":false,
                        "loading":false
                    });
                }else{
                    parent.layer.alert(r.msg);
                }
            },
            error: function (r) {
                parent.layer.alert(r.msg);
            }
        });
    });

    layui.use('upload', function () {
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '.uploadImg2',
            url: ctx+'/upload/uploadImg',
            size: 20480,
            accept: 'images',
            exts:'jpg|png|JPEG|GIF',
            method:'post',
            data:{},
            before:function(){
            },
            done: function (r) {
                if("0" == r.code){
                    parent.layer.alert("上传成功");
                    $(".resourceImg2").remove();
                    var html = '<div class="col-sm-3 col-md-3 resourceImg">' +
                        '   <div class="thumbnail">' +
                        '      <img class="imgUrl" data-toggle="tooltip" imgName="'+r.fileName+'" title="点击预览大图" src="'+r.fileUrl+'">' +
                        '   </div>' +
                        '</div>';
                    $(".uploadImg2").before(html);
                    $(":hidden[name=img2]").val(r.fileUrl);;
                    $('#logImg2 img').viewer({
                        "navbar":false,
                        "title":false,
                        "toolbar":false,
                        "tooltip":false,
                        "loading":false
                    });
                }else{
                    parent.layer.alert(r.msg);
                }
            },
            error: function (r) {
                parent.layer.alert(r.msg);
            }
        });
    });

    layui.use('upload', function () {
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '.uploadImg3',
            url: ctx+'/upload/uploadImg',
            size: 20480,
            accept: 'images',
            exts:'jpg|png|JPEG|GIF',
            method:'post',
            data:{},
            before:function(){
            },
            done: function (r) {
                if("0" == r.code){
                    parent.layer.alert("上传成功");
                    $(".resourceImg3").remove();
                    var html = '<div class="col-sm-3 col-md-3 resourceImg">' +
                        '   <div class="thumbnail">' +
                        '      <img class="imgUrl" data-toggle="tooltip" imgName="'+r.fileName+'" title="点击预览大图" src="'+r.fileUrl+'">' +
                        '   </div>' +
                        '</div>';
                    $(".uploadImg3").before(html);
                    $(":hidden[name=img3]").val(r.fileUrl);
                    $('#logImg3 img').viewer({
                        "navbar":false,
                        "title":false,
                        "toolbar":false,
                        "tooltip":false,
                        "loading":false
                    });
                }else{
                    parent.layer.alert(r.msg);
                }
            },
            error: function (r) {
                parent.layer.alert(r.msg);
            }
        });
    });
    

    layui.use('upload', function () {
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '.uploadImg4',
            url: ctx+'/upload/uploadImg',
            size: 20480,
            accept: 'images',
            exts:'jpg|png|JPEG|GIF',
            method:'post',
            data:{},
            before:function(){
            },
            done: function (r) {
                if("0" == r.code){
                    parent.layer.alert("上传成功");
                    $(".resourceImg").remove();
                    var html = '<div class="col-sm-3 col-md-3 resourceImg">' +
                        '   <div class="thumbnail">' +
                        '      <img class="imgUrl" data-toggle="tooltip" imgName="'+r.fileName+'" title="点击预览大图" src="'+r.fileUrl+'">' +
                        '   </div>' +
                        '</div>';
                    $(".uploadImg4").before(html);
                    $(":hidden[id=img]").val(r.fileUrl);
                    $('#logImg img').viewer({
                        "navbar":false,
                        "title":false,
                        "toolbar":false,
                        "tooltip":false,
                        "loading":false
                    });
                }else{
                    parent.layer.alert(r.msg);
                }
            },
            error: function (r) {
                parent.layer.alert(r.msg);
            }
        });
    });
});